/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sirtet;

import java.util.ArrayList;
import java.util.List;

/**
 * An abstract factory that create pieces
 * @author guangwei.zhu
 */
public abstract class PieceFactory {

    /**
     * Construct a Piece instance from its string representation
     * @param data a string representation of a TetrisPiece
     * @return the constructed Piece
     */
    public abstract Piece fromString(String data);
    
    /**
     * Construct multiple Piece instances from an array of string representations
     * @param data an array of string representations of TetrisPieces
     * @return a list of the constructed Piece instances
     */
    public List<Piece> fromStrings(String[] data)
    {
        ArrayList<Piece> pieces = new ArrayList<Piece>();

        for (String str : data) {
            pieces.add(this.fromString(str));
        }

        return (List<Piece>) pieces;
    }
    
}
